CMAKE_MINIMUM_REQUIRED(VERSION 2.8)

PROJECT(GmSSLServer)

SET(OUT_PUT_DIR ${PROJECT_SOURCE_DIR}/build/GmSSLServer)
SET(OUT_TAR_DIR ${PROJECT_SOURCE_DIR}/build)
SET(OUT_TAR_FILE "${PROJECT_SOURCE_DIR}/build/GmSSLServer.tar.tgz")

FILE(REMOVE_RECURSE ${OUT_PUT_DIR})
FILE(MAKE_DIRECTORY ${OUT_PUT_DIR})

SET(EXECUTABLE_OUTPUT_PATH ${OUT_PUT_DIR})

MESSAGE(STATUS "HOME dir: ${PROJECT_SOURCE_DIR}")

AUX_SOURCE_DIRECTORY(. SRC_LIST)

FOREACH(F ${SRC_LIST})
    MESSAGE(STATUS "source file: ${F}")
ENDFOREACH(F)

INCLUDE_DIRECTORIES(/usr/local/taf/cpp/include)
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/GmSSL/include)

LINK_DIRECTORIES(/usr/local/taf/cpp/lib ${PROJECT_SOURCE_DIR}/GmSSL/libs)

ADD_EXECUTABLE(GmSSLServer ${SRC_LIST})

TARGET_LINK_LIBRARIES(GmSSLServer libtafservant.so libtafutil.so pthread dl libssl.a libcrypto.a)

INSTALL(FILES GmSSLServer.conf DESTINATION ${OUT_PUT_DIR})

ADD_CUSTOM_TARGET(release 
COMMAND tar zcvf ${OUT_TAR_FILE} -C ${OUT_TAR_DIR} ${PROJECT_NAME}/${PROJECT_NAME} ${PROJECT_NAME}/${PROJECT_NAME}.conf
)


